﻿using System;
using PMS.XCMG.Entity;
using PMS.XCMG.IBusiness;
using PMS.XCMG.Models;
using PMS.XCMG.Util;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;

namespace PMS.XCMG.Api.Controllers
{
    /// <summary>
    /// CF_District
    /// </summary>
    public class CF_DistrictController : BaseController
    {
        public ICF_DistrictBusiness Bus { get; set; }
        public IServiceProvider SvcProvider { get; set; }
        public CF_DistrictController(ICF_DistrictBusiness bus, IServiceProvider svcProvider)
        {
            this.Bus = bus;
            this.SvcProvider = svcProvider;
        }

        /// <summary>
        /// 获取单个实体
        /// </summary>
        /// <param name="id">主键</param>
        /// <returns></returns>
        [HttpGet]
        public Task<List<CF_District>> GetAsync(string id)
        {
            return this.Bus.GetByParentAsync(id);
        }

        /// <summary>
        /// 获取分页数据
        /// </summary>
        /// <param name="query">查询条件</param>
        /// <returns></returns>
        [HttpPost]
        public Task<PageResult<CF_District>> GetPageAsync(PageInput<CF_DistrictQM> query)
        {
            return this.Bus.GetPageResultAsync(query);
        }

        ///// <summary>
        ///// 保存数据
        ///// </summary>
        ///// <param name="data">对应数据</param>
        ///// <returns></returns>
        //[HttpPost]
        //[Transaction]
        //public Task<int> SaveAsync(CF_District data)
        //{
        //    this.InitBusEntity(data);
        //    return this.Bus.AddOrUpdateAsync(data);
        //}

        /// <summary>
        /// 批量删除数据
        /// </summary>
        /// <param name="ids">数据主键</param>
        /// <returns></returns>
        [HttpDelete]
        [Transaction]
        public Task<int> DeleteAsync(List<string> ids)
        {
            return this.Bus.DeleteAsync(ids);
        }
    }
}


